import { defineStore } from "pinia";
export const useViewStore = defineStore("navView", {
    state: () => {
        return {
            allViews: [] as any,
            cachedViews: [],
            removedViews: []
        };
    },
    getters: {},
    actions: {
        addVisitedView(view: any) {
            if (this.allViews.every((i: any) => i.path !== view.path)) {
                this.allViews.push(view)
            }
        },
        removeVisitedView(view: any) {
            const index = this.allViews.findIndex((i: any) => i.path === view.path)
            if (index !== -1) {
                this.allViews.splice(index, 1)
            }
        }
    },
    persist: {
        enabled: true,
        strategies: [
            {
                key: "navView",
                storage: sessionStorage,
            },
        ],
    }
});
